package com.hay.pay.util;

import com.hay.pay.exception.PayException;
import lombok.extern.slf4j.Slf4j;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author LiMouRen
 * @date 2024/2/2
 */
public class DateUtil {

    public static Date parse(String dateStr,String pattern){
        Date date = null;
        try {
            date = new SimpleDateFormat(pattern).parse(dateStr);
        } catch (Exception e) {
            throw new PayException(e.getMessage());
        }
        return date;
    }

    public static String format(Date date,String pattern){
        SimpleDateFormat dateFormat = new SimpleDateFormat(pattern);
        return dateFormat.format(date);
    }

}
